﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for CommentBus
/// </summary>
public class CommentBus
{
    CommentDAL cmDAL;
	public CommentBus()
	{
        cmDAL = new CommentDAL();
    }
    public bool Insert_UpdateComment(Comment comment)
    {
        bool check = false;
        if (cmDAL.Insert_UpdateComment(comment) != 0) 
        {
            check = true;
        }
        return check;
    }
    public DataTable getAllComment() 
    {
        return cmDAL.getAllComment();
    }
    public Comment getCommentByID(int comment_id) 
    {
        DataTable dt = cmDAL.getCommentByID(comment_id);
        Comment cmt = new Comment();
        cmt.Article_id = Convert.ToInt32(dt.Rows[0]["article_id"].ToString());
        cmt.Comment_name = dt.Rows[0]["comment_name"].ToString();
        cmt.Comment_des = dt.Rows[0]["comment_des"].ToString();
        cmt.Email = dt.Rows[0]["email"].ToString();
        cmt.Status = Convert.ToBoolean(dt.Rows[0]["status"].ToString());
        return cmt;
    }
    public DataTable getCommentByArticle(int article_id)
    {
        return cmDAL.getCommentByArticle(article_id);
    }
    public DataTable getCommentByEmail(string email) 
    {
        return cmDAL.getCommentByEmail(email);
    }
    public string getEmailByUserName(string username)
    {
        DataTable dt = cmDAL.getEmailByUserName(username);
        string email = dt.Rows[0]["email"].ToString();
        return email;
    }
}